import request from '../../utils/request'

Component({
  /**
   * 组件的属性列表
   */
  properties: {
    isReachBottom: Boolean
  },

  /**
   * 组件的初始数据
   */
  data: {
    nearbyShopsInfo: []
  },

  observers: {
    'isReachBottom': function() {
      if(this.properties.isReachBottom) {
        console.log('加载')
        this.getNearbyShops()
      }
    }
  },
  lifetimes: {
    attached() {
      this.getNearbyShops()
    }
  },

  /**
   * 组件的方法列表
   */
  methods: {
    async getNearbyShops() {
      let result = await request('/getNearbyShops')
      
      this.setData({
        nearbyShopsInfo: result.data.shops
      })
    }
  }
})
